package com.ehotting.edsta.signalAnalysis.aop;

import com.alibaba.fastjson.JSON;
import com.ehotting.edsta.mqbd.signal.api.bean.MqSignalTcpData;
import com.ehotting.edsta.mqbd.signal.client.handler.SISendUserServiceAble;
import com.ehotting.edsta.signalAnalysis.controller.SignalAnalysisWsController;
import com.ehotting.mqbd.api.bean.MQDataAble;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SISendUserService extends SISendUserServiceAble {

    @Autowired
    private SignalAnalysisWsController wsController;

    @Override
    public void sendToUser(MQDataAble mqData) {
        log.info("response:{}",JSON.toJSONString(mqData.getResponse()));
        String agentId = mqData.getAgentId();
        log.info("agentId:{}",agentId);
        if(mqData.getResponse()==null){
            log.info("mqData.getResponse() is null,return.",mqData.getResponseString());
            return;
        }

        try {
            wsController.sendUserMessage(JSON.toJSONString(mqData.getResponse()),agentId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
